package top.lshaci.learning.nio;

import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

/**
 * MappedByteBufferTest
 *
 * @author lshaci
 * @since 1.0.0
 */
public class MappedByteBufferTest {

    public static void main(String[] args) throws Exception {
        String filename = "E:/NIO1.txt";

        try (RandomAccessFile accessFile = new RandomAccessFile(filename, "rw")) {
            final FileChannel channel = accessFile.getChannel();
            final MappedByteBuffer mappedByteBuffer = channel.map(FileChannel.MapMode.READ_WRITE, 0, 5);

            mappedByteBuffer.putChar('Y');
        }
    }
}
